import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import vx from '../store/index'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'Home',
    component: Home
  },
  {
    path: '/about',
    component: () => import('../views/About.vue')
  },
  {
    path: '/adetail',
    component: () => import('../views/AboutDetail.vue')
  },
  {
    path: '/his',
    name: 'his',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/His.vue')
  },
  {
    path: '/user',
    name: 'user',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/User.vue')
  },
  {
    path: '/seach',
    name: 'seach',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/Seach.vue')
  }
]

const router = new VueRouter({
  routes
})
router.afterEach( route => {
  if(route.path=='/his'||route.path=='/home'||route.path=='/about'||route.path=='/user'){
    vx.commit('setFlgShow2')
  }else{
    vx.commit('setFlgShow1')
  }
})

export default router
